home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / GSRC208A.ZIP / EDOTASK.C < prev    next >
C/C++ Source or Header  |  1992-12-06  |  5KB  |  154 lines

  1. #include "copyleft.h"
  2.  
  3. /*
  4.     GEPASI - a simulator of metabolic pathways and other dynamical systems
  5.     Copyright (C) 1989, 1992  Pedro Mendes
  6. */
  7.  
  8. /*************************************/
  9. /*                                   */
  10. /*         GWSIM - Simulation        */
  11. /*        MS-WINDOWS front end       */
  12. /*                                   */
  13. /*               Tasks               */
  14. /*            dialog box             */
  15. /*                                   */
  16. /*           QuickC/WIN 1.0          */
  17. /*                                   */
  18. /*   (include here compilers that    */
  19. /*   compiled GWSIM successfully)    */
  20. /*                                   */
  21. /*************************************/
  22.  
  23.  
  24. #include <windows.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <math.h>
  28. #include "defines.h"                    /* symbols also used in .DLG files        */
  29. #include "globals.h"                    /* gepasi's own symbols                    */
  30. #include "gwsim.h"                        /* macros, function prototypes, etc.    */
  31. #include "gep2.h"                        /* gepasi's variables                    */
  32. #include "simgvar.h"                    /* global variables                        */
  33. #include "strtbl.h"                        /* symbols for the string table            */
  34.  
  35. #pragma alloc_text( CODE3, EdOTask)
  36.  
  37. BOOL FAR PASCAL EdOTask(HWND hDlg, WORD message, WORD wParam, LONG lParam)
  38. {
  39.  static    HWND    hEndTime,
  40.                  hPoints,
  41.                  hStat1,
  42.                  hStat2,
  43.                  hDyn,
  44.                  hSS,
  45.                  hRep,
  46.                  hDat,
  47.                  hLog;
  48.  char buff[32];
  49.  char *dummy;
  50.  int len;
  51.  
  52.  switch( message )
  53.  {
  54.   case WM_INITDIALOG:
  55.    /* get handles to controls                                        */
  56.    hEndTime = GetDlgItem( hDlg, IDE_M0 );
  57.    hPoints = GetDlgItem( hDlg, IDE_M1 );
  58.    hStat1 = GetDlgItem( hDlg, IDSTAT_1 );
  59.    hStat2 = GetDlgItem( hDlg, IDSTAT_4 );
  60.    hDyn = GetDlgItem( hDlg, IDC_DYNAMICS );
  61.    hSS = GetDlgItem( hDlg, IDC_SS );
  62.    hRep = GetDlgItem( hDlg, IDC_TXT );
  63.    hDat = GetDlgItem( hDlg, IDC_DAT );
  64.    hLog = GetDlgItem( hDlg, IDC_LOG );
  65.  
  66.    /* fill in the current set of options                            */
  67.    gcvt( options.endtime, 8, buff );
  68.    SendMessage( hEndTime, WM_SETTEXT, 0, (DWORD)(LPSTR)  buff );
  69.    itoa( (int) options.pfo, buff, 10 );
  70.    SendMessage( hPoints, WM_SETTEXT, 0, (DWORD)(LPSTR)  buff );
  71.    SendMessage( hDyn, BM_SETCHECK, (WORD) options.dyn, 0 );
  72.    SendMessage( hDlg, WM_COMMAND, IDC_DYNAMICS, 0 );
  73.    SendMessage( hSS, BM_SETCHECK, (WORD) options.ss, 0 );
  74.    SendMessage( hRep, BM_SETCHECK, (WORD) options.txt, 0 );
  75.    SendMessage( hDat, BM_SETCHECK,  (WORD) options.dat, 0 );
  76.    SendMessage( hLog, BM_SETCHECK,  (WORD) options.debug, 0 );
  77.  
  78.    return TRUE;
  79.  
  80.   case WM_COMMAND:
  81.    switch( wParam )
  82.    {
  83.     case IDC_DYNAMICS:
  84.      if( SendMessage( hDyn, BM_GETCHECK, 0, 0 ) )
  85.      {
  86.       EnableWindow( hEndTime, TRUE );
  87.       EnableWindow( hStat1, TRUE );
  88.       EnableWindow( hPoints, TRUE );
  89.       EnableWindow( hStat2, TRUE );
  90.      }
  91.      else
  92.      {
  93.       EnableWindow( hEndTime, FALSE );
  94.       EnableWindow( hStat1, FALSE);
  95.       EnableWindow( hPoints, FALSE );
  96.       EnableWindow( hStat2, FALSE );
  97.      }
  98.      return TRUE;
  99.  
  100.     case IDC_HELP:                        /* Help for this Dialog Box             */
  101.        WinHelp( hDlg, (LPSTR) szHelpFile, HELP_KEY, (DWORD) (LPSTR) "Execution tasks" );
  102.      return TRUE;
  103.  
  104.     case IDOK:
  105.      /* read all variables from the controls        */
  106.      options.debug = (int) SendMessage( hLog, BM_GETCHECK, 0, 0 );
  107.      options.dyn   = (int) SendMessage( hDyn, BM_GETCHECK, 0, 0 );
  108.      options.ss    = (int) SendMessage( hSS, BM_GETCHECK, 0, 0 );
  109.      options.dat   = (int) SendMessage( hDat, BM_GETCHECK, 0, 0 );
  110.      options.txt   = (int) SendMessage( hRep, BM_GETCHECK, 0, 0 );
  111.      if( options.dyn )
  112.      {
  113.       len = (int) SendMessage( hEndTime, WM_GETTEXT, (WORD) sizeof( buff ), (DWORD)(LPSTR) buff );
  114.       if( len==0) options.endtime = dft_endtime;
  115.       else options.endtime = strtod( buff, &dummy );
  116.       if( (options.endtime==HUGE_VAL) || (options.endtime==-HUGE_VAL) )
  117.       {
  118.        LoadString(hInst, IDS_ERR_OVERFLOW, szString, sizeof(szString));
  119.        MessageBox(hDlg, szString, NULL, MB_ICONEXCLAMATION);
  120.        SetFocus( hEndTime );
  121.        return TRUE;
  122.       }
  123.       len = (int) SendMessage( hPoints, WM_GETTEXT, (WORD) sizeof( buff ), (DWORD)(LPSTR) buff );
  124.       if( len==0) options.pfo = dft_pfo;
  125.       else
  126.       {
  127.        len = atoi( buff );
  128.        if( (len<=0) )
  129.        {
  130.         LoadString(hInst, IDS_ERR_ZEROBAD, szString, sizeof(szString));
  131.         MessageBox(hDlg, szString, NULL, MB_ICONEXCLAMATION);
  132.         SetFocus( hPoints );
  133.         return TRUE;
  134.        }
  135.        options.pfo = len;
  136.  
  137.       }
  138.      }
  139.  
  140.      /* signal that changes were made                */
  141.      notsaved = 1;
  142.      /* close the dialog box and return                */
  143.      EndDialog( hDlg, IDOK );
  144.      return TRUE;
  145.  
  146.     case IDCANCEL:
  147.      /* close the dialog box and return            */
  148.      EndDialog( hDlg, IDCANCEL );
  149.      return TRUE;
  150.    }
  151.  
  152.   default: return FALSE;
  153.  }
  154. }